import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.HashMap;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //M表示内存长度
        int M = in.nextInt();
        //N表示文章长度
        int N = in.nextInt();

        int[] arr = new int[N];
        for(int i = 0; i < N; i++){
            arr[i] = in.nextInt();
        }

        HashMap<Integer,Integer> map = new HashMap<>();
        Queue<Integer> queue = new LinkedList<>();
        int count = 0;
        for(int word : arr){
            if(!map.containsKey(word)){
                count++;
                if(queue.size() >= M){
                    int delete = queue.poll();
                    map.remove(delete);
                }
                queue.offer(word);
                map.put(word,0);
            }
        }
        System.out.println(count);
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 0; i < n + 1; i++) {
            arr[i] = in.nextInt();
        }
        in.close();
        StringBuilder str = new StringBuilder();

        // 处理首项
        if (arr[0] != 0) {
            if (n == 0) {
                str.append(arr[0]);
            } else {
                int exponent = n;
                String xPart = exponent == 1 ? "x" : "x^" + exponent;
                if (arr[0] == 1) {
                    str.append(xPart);
                } else if (arr[0] == -1) {
                    str.append("-").append(xPart);
                } else {
                    str.append(arr[0]).append(xPart);
                }
            }
        }

        // 处理中间项（i从1到n-1）
        for (int i = 1; i < n; i++) {
            if (arr[i] != 0) {
                int exponent = n - i;
                String xPart = exponent == 1 ? "x" : "x^" + exponent;
                // 处理符号和系数
                if (arr[i] > 0) {
                    str.append("+");
                    if (arr[i] != 1) {
                        str.append(arr[i]);
                    }
                } else {
                    if (arr[i] == -1) {
                        str.append("-");
                    } else {
                        str.append(arr[i]);
                    }
                }
                str.append(xPart);
            }
        }

        // 处理常数项（仅当n>0时）
        if (n > 0 && arr[n] != 0) {
            if (arr[n] > 0) {
                str.append("+");
            }
            str.append(arr[n]);
        }

        // 处理全零的情况
        if (str.length() == 0) {
            System.out.println(0);
        } else {
            System.out.println(str.toString());
        }
    }
}